﻿
@{

}
<div class="bjui-pageContent">
    <table class="table table-bordered" id="datagrid-Word@(Request.QueryString["_"])" data-toggle="datagrid"></table>
</div>
<script type="text/javascript">
    var langGrid@(Request.QueryString["_"]) = $('#datagrid-Word@(Request.QueryString["_"])');
    langGrid@(Request.QueryString["_"]).datagrid({
        height: '100%',
        width: '100%',
        showToolbar: true,
        //toolbarItem: 'refresh,add,edit,save,exportf,del',
        toolbarItem: 'refresh,add,edit,save,del',
        dataUrl: '/Word/WordSearch',
        dataType: 'json',
        //editMode: { dialog: { width: 800, height: 250, mask: true, faicon: 'caret-right', icon: 'plus', title: "编辑", fresh: true } },
         postData: { typeid: "@Request.QueryString["typeid"]" },
        clearOldPostData:false,
        editMode: "inline",
        editUrl: '/Word/WordUpsert?typeid=@(Request.QueryString["typeid"])',
        afterSave: saveCallBack@(Request.QueryString["_"]),
        delUrl: '/Word/DelWord',
        delPK: 'id',
        paging: { pageSize: 20, orders: 'ADDED desc' },
        inlineEditMult: false,
        filterThead: true,
        linenumberAll: true,
        fieldSortable: true,
        columnFilter: true,
        showCheckboxcol: false,
        toolbarCustom: customtBtn@(Request.QueryString["_"]),
        exportOption: { type: "file", options: { url: "/Word/WordExport", outPutFileName: '类别详情' } },
        columns: [
            { name: 'id', align: 'center', width: 100, label: '@Html.CurLang("ID")', finalwidth: true, hide: true },
            { name: 'zh', align: 'center', width: 300, label: '简体中文' },
            { name: 'en', align: 'center', width: 300, label: 'English' },
            //{ name: 'jp', align: 'center', width: 250, label: '日本語' },
            //{ name: 'kor', align: 'center', width: 250, label: '한국어' },
            { name: 'spa', align: 'center', width: 300, label: 'Español' },
            { name: 'remark', align: 'center', width: 250, label: '@Html.CurLang("备注")' },
            { name: 'added', align: 'center', width: 250, label: '@Html.CurLang("添加时间")', type: 'date', pattern: 'yyyy-MM-dd HH:mm:ss', add: false, edit: false }         
        ]
    });


    function fanyin@(Request.QueryString["_"])() {
        BJUI.alertmsg('confirm', '@Html.CurLang("已经翻译的是否需要替换？")', {
            okName: '@Html.CurLang("是")', cancelName: '@Html.CurLang("否")', okCall: function () {
                fanyinReq@(Request.QueryString["_"])(true);
            }, cancelCall: function () {
                fanyinReq@(Request.QueryString["_"])(false);
            }
        });
    }

    function fanyinReq@(Request.QueryString["_"])(isOK) {
        $.ajax({
            url: "/Lang/FanYin",
            type: "POST",
            data: { "type": "word", "isReplace": isOK },
            dataType: "json",
            async: true,
            cache: false,
            success: function (res) {
                if (res.Code === 1) {
                    BJUI.alertmsg("ok", '@Html.CurLang("文本内容已翻译完成！")', { alertTimeout: 2000 });
                    setTimeout(refreshGri@(Request.QueryString["_"]), 2000);
                } else {
                    BJUI.alertmsg('error', res.Msg);
                }
            },
            error: function (xhr, status, errorThrown) {
                BJUI.alertmsg('error', xhr.statusText);
            }

        });
    }

    function refreshGri@(Request.QueryString["_"])() {
        langGrid@(Request.QueryString["_"]).datagrid('filter', {});
        //langGrid@(Request.QueryString["_"]).datagrid('filter', { "clearOldPostData": true });
    }
    function customtBtn@(Request.QueryString["_"])() {
        return $("<button type='button' class='btn-default btn' onclick='fanyin@(Request.QueryString["_"])()'>" + '@Html.CurLang("实时翻译")' + "</button> <button type='button' class='btn-default btn' onclick='refreshGri@(Request.QueryString["_"])()'>@Html.CurLang("清空查询")</button>");
    }

    function saveCallBack@(Request.QueryString["_"])($trs, datas) {
        langGrid@(Request.QueryString["_"]).datagrid('refresh', false);
    }

 
</script>
